function LoadJS( file_ )
{
	// should add domain here, or admin pages can not work
	document.write( "<script type=\"text/javascript\" src=\""+edp_static_domain_url+"js/" + file_ +   "\"> <\/script>" );
} 

var messageStack = new Array();

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function isInteger(val)
{
    if(val==null)
    {
        return false;
    }
    if (val.length==0)
    {
        return false;
    }
    for (var i = 0; i < val.length; i++)
    {
        var ch = val.charAt(i)
        if (i == 0 && ch == "-")
        {
            continue
        }
        if (ch < "0" || ch > "9")
        {
            return false
        }
    }
    return true
}

function trim(str)
{
	return str.replace(/(^\s*)|(\s*$)/g, "");  
} 

//use regex to check whether current url contains page information
function GotoPage(){
	var page = $( "#gotopage").val();
	if( isInteger(page) ){
		var currentUrl = window.location.href;

		if( currentUrl.indexOf( "&p=" ) >= 0 ){
			//replace current url's p option to new one
			var newUrl = currentUrl.replace(/&p=\d+/, "&p="+page);
			window.location = newUrl;
		}
		else{
			currentUrl += "&p="+page;
			window.location = currentUrl;
		}
	}
	else{
		alert( "请输入数字" );
	}
}

var cityMap = new Object();
cityMap['北京']=new Array('北京');
cityMap['上海']=new Array('上海');
cityMap['天津']=new Array('天津');
cityMap['重庆']=new Array('重庆');
cityMap['安徽']=new Array('合肥','安庆','蚌埠','亳州','巢湖','滁州','阜阳','贵池','淮北','淮化','淮南','黄山','九华山','六安','马鞍山','宿州','铜陵','屯溪','芜湖','宣城');
cityMap['辽宁']=new Array('朝阳','沈阳','鞍山','本溪','大连','丹东','抚顺','阜新','葫芦岛','锦州','辽阳','盘锦','铁岭','营口');
cityMap['四川']=new Array('涪陵','成都','巴中','达川','德阳','都江堰','峨眉山','广安','广元 ','九寨沟','康定','乐山','泸州 ','马尔康','绵阳','眉山','南充','内江','攀枝花','遂宁','汶川','西昌','雅安','宜宾','自贡','资阳');
cityMap['福建']=new Array('福州','福安','龙岩','南平','宁德','莆田','泉州','三明','邵武','石狮','永安','武夷山','厦门','漳州');
cityMap['甘肃']=new Array('兰州','白银','定西','敦煌','甘南','金昌','酒泉','临夏','平凉','天水','武都','武威','西峰','张掖');
cityMap['广东']=new Array('广州','潮阳','潮州','澄海','东莞','佛山','河源','惠州','江门', '揭阳','开平','茂名','梅州',' 清远','汕头','汕尾','韶关','深圳','顺德','阳江','英德','云浮','增城','湛江','肇庆','中山','珠海');
cityMap['广西']=new Array('南宁','百色','北海','桂林','防城港','河池','贺州','柳州','钦州 ','梧州','玉林','贵阳','安顺','毕节','都匀','凯里','六盘水','铜仁','兴义','玉屏','遵义');
cityMap['海南']=new Array('海口','儋县','陵水','琼海','三亚','通什','万宁');
cityMap['河北']=new Array('石家庄','保定','北戴河','沧州','承德','丰润','邯郸','衡水','廊坊','南戴河','秦皇岛','唐山','新城','邢台','张家口');
cityMap['黑龙江']=new Array('哈尔滨','北安','大庆','大兴安岭','鹤岗','黑河','佳木斯','鸡西','牡丹江','齐齐哈尔','七台河','双鸭山','绥化','伊春');
cityMap['河南']=new Array('郑州','安阳','鹤壁','潢川','焦作','济源','开封','漯河','洛阳','南阳','平顶山','濮阳','三门峡','商丘','新乡','信阳','许昌','周口','驻马店');
cityMap['香港']=new Array('香港','九龙','新界');
cityMap['湖北']=new Array('武汉','恩施','鄂州','黄冈','黄石','荆门','荆州','潜江','十堰','随州','武穴','仙桃','咸宁','襄阳','襄樊','孝感','天门','宜昌');
cityMap['湖南']=new Array('长沙','常德','郴州','衡阳','怀化','吉首','娄底','邵阳','湘潭','益阳','岳阳','永州','张家界','株洲');
cityMap['江苏']=new Array('南京','常熟','常州','海门','淮安','江都','江阴','昆山','连云港 ','南通','启东','沭阳','宿迁','苏州','太仓','泰州','同里','无锡','徐州','盐城','扬州','宜兴','仪征', '张家港','镇江');
cityMap['江西']=new Array('南昌','抚州','赣州','吉安','景德镇','井冈山','九江','庐山','萍乡','上饶','新余','宜春','鹰潭');
cityMap['吉林']=new Array('长春','白城','白山','珲春','辽源','梅河','吉林','四平','松原','通化','延吉');
cityMap['澳门']=new Array('澳门');
cityMap['内蒙古']=new Array('呼和浩特','阿拉善盟','包头','赤峰','东胜','海拉尔','集宁','临河','通辽','乌海','乌兰浩特','锡林浩特');
cityMap['宁夏']=new Array('银川','固源','石嘴山','吴忠');
cityMap['青海']=new Array('西宁','德令哈','格尔木','共和','海东','海晏','玛沁','同仁','玉树');
cityMap['山东']=new Array('济南','滨州','兖州','德州','东营','菏泽','济宁','莱芜','聊城','临沂','蓬莱','青岛','曲阜','日照','泰安','潍坊','威海','烟台','枣庄','淄博');
cityMap['山西']=new Array('太原','长治','大同','候马','晋城','离石','临汾','宁武','朔州','忻州','阳泉','榆次','运城');
cityMap['陕西']=new Array('西安','安康','宝鸡','汉中','渭南','商州','绥德','铜川','咸阳','延安','榆林');
cityMap['台湾']=new Array('台北','基隆','台南','台中','高雄','屏东','南投','云林','新竹','彰化','苗栗','嘉义','花莲','桃园','宜兰','台东','金门','马祖','澎湖');
cityMap['新疆']=new Array('乌鲁木齐','阿克苏','阿勒泰','阿图什','博乐','昌吉','东山','哈密','和田','喀什','克拉玛依','库车','库尔勒','奎屯','石河子','塔城','吐鲁番','伊宁');
cityMap['西藏']=new Array('拉萨','阿里','昌都','林芝','那曲','日喀则','山南');
cityMap['云南']=new Array('昆明','大理','保山','楚雄','东川','个旧','景洪','开远','临沧','丽江','六库','潞西','曲靖','思茅','文山','西双版纳','玉溪','中甸','昭通');
cityMap['浙江']=new Array('杭州','安吉','慈溪','定海','奉化','海盐','黄岩','湖州','嘉兴', '金华','临安','临海','丽水','宁波','瓯海','平湖','千岛湖','衢州','江山','瑞安','绍兴','嵊州','台州','温岭','温州','舟山');
cityMap['港澳台'] =new Array('香港','澳门','台湾');
cityMap['海外'] = new Array('美国','英国','法国','瑞士','澳洲','新西兰','加拿大','奥地利','韩国','日本','德国','意大利','西班牙','俄罗斯','泰国','印度','荷兰','新加坡','其它国家');

var shopCateMap = new Object();
shopCateMap['服饰']=new Array('男装', '运动鞋', '女装/流行女装', '女鞋', '女士内衣/男士内衣/家居服', '箱包皮具/热销女包/男包', '流行男鞋/皮鞋', '童装/婴儿服/鞋帽', '运动服', '服饰配件/皮带/帽子/围巾');
shopCateMap['手机/数码/办公/家电']=new Array('手机', '笔记本电脑', '电脑硬件/台式机/网络设备', 'MP3/MP4/iPod/录音笔', '数码相机/摄像机/图形冲印', '3C数码配件市场', '家用电器/hifi音响/耳机', '网络服务/电脑软件', '闪存卡/U盘/移动存储', '办公设备/文具/耗材');
shopCateMap['家具/母婴/食品']=new Array('居家日用/厨房餐饮/卫浴洗浴', '时尚家饰/工艺品/十字绣', '家具/家具定制/宜家代购', '床上用品/靠垫/窗帘/布艺', '装潢/灯具/五金/安防/卫浴', '保健品/滋补品', '食品/茶叶/零食/特产', '母婴用品/奶粉/孕妇装', '宠物/宠物食品及用品', '成人用品/避孕用品/情趣内衣');
shopCateMap['美容护肤/个人护理']=new Array('个人护理/保健/按摩器材', '彩妆/香水/护肤/美体');
shopCateMap['运动/汽车']=new Array('运动/瑜伽/健身/球迷用品', '户外/军品/旅游/机票', '汽车/配件/改装/摩托/自行车', '书籍/杂志/报纸', '音乐/影视/明星/乐器');
shopCateMap['珠宝/首饰']=new Array('珠宝/钻石/翡翠/黄金', '品牌手表/流行手表', '饰品/流行首饰/时尚饰品');
shopCateMap['收藏/爱好']=new Array('ZIPPO/瑞士军刀/饰品/眼镜', '玩具/动漫/模型/卡通', '古董/邮币/字画/收藏');  
shopCateMap['游戏/话费']=new Array('IP卡/网络电话/在线影音充值', '移动联通充值中心/IP长途', '腾讯QQ专区', '网络游戏装备/游戏币/帐号/代练', '电玩/配件/游戏/攻略', '网络游戏点卡');   
shopCateMap['生活服务']=new Array('网店装修/物流快递/图片存储', '演出/旅游/吃喝玩乐折扣券', '鲜花速递/蛋糕配送/园艺花艺');	  
		

//商品静态关系，add product时候用到
var productCateMap=new Object();
productCateMap['服饰鞋包']=new Array('女装/女士精品','男装','流行男鞋','女鞋','女士内衣/男士内衣/家居服','运动服/运动包/颈环配件','运动鞋','箱包皮具/热销女包/男包','服饰配件/皮带/帽子/围巾');
productCateMap['3C数码']=new Array('数码相机/摄像机/摄影器材','3C数码配件市场','电脑硬件/显示器/电脑周边','网络设备/网络相关','台式机/一体机/服务器','闪存卡/U盘/存储/移动硬盘','电子词典/电纸书/文化用品','MP3/MP4/iPod/录音笔','手机','国货精品手机','笔记本电脑','厨房电器','生活电器','个人护理/保健/按摩器材', '影音电器','电玩/配件/游戏/攻略');
productCateMap['美容护肤']=new Array('彩妆/香水/美发/工具','美容护肤/美体/精油');
productCateMap['珠宝配饰']=new Array('品牌手表/流行手表','珠宝/钻石/翡翠/黄金','饰品/流行首饰/时尚饰品新');
productCateMap['家居用品']=new Array('居家日用/收纳/礼品','厨房/餐饮用具','日化/清洁/护理','床上用品/靠垫/毛巾/布艺');
productCateMap['母婴用品']=new Array('奶粉/辅食/营养品','尿片/洗护/喂哺等用品','益智玩具/早教/童车床/出行','童装/童鞋/孕妇装');          
productCateMap['食品保健']=new Array('零食/坚果/茶叶/特产','滋补/生鲜/速食/订餐','保健食品');         
productCateMap['家装家饰']=new Array('装潢/灯具/五金/安防/卫浴','家装饰品/窗帘/地毯','家具/家具定制/宜家代购');         
productCateMap['文体汽车']=new Array('运动/瑜伽/健身/球迷用品','户外/登山/野营/旅行用品','汽车/用品/配件/改装/摩托','宠物/宠物食品及用品','乐器/吉他/钢琴/配件', '音乐/影视/明星/音像','书籍/杂志/报纸','办公设备/耗材/相关服务');
productCateMap['收藏爱好']=new Array('ZIPPO/瑞士军刀/眼镜','古董/邮币/字画/收藏', '玩具/娃娃/模型/动漫/桌游');
productCateMap['生活服务']=new Array('鲜花速递/花卉仿真/绿植园艺','演出/吃喝玩乐折扣券','网店/网络服务/个性定制/软件','特价机票','特价机票/门票旅游/酒店客栈','成人用品/避孕/计生用品');
productCateMap['虚拟话费']=new Array('腾讯QQ专区','网游装备/游戏币/帐号/代练','IP卡/网络电话/手机号码','网络游戏点卡', '移动/联通/小灵通充值中心');
productCateMap['其他']=new Array('二维码凭证', '其它');	 

function displaySubMenu(li) 
{ 
	var subMenu = li.getElementsByTagName("ul")[0]; 
	subMenu.style.display = "block"; 
} 

function hideSubMenu(li) 
{ 
	var subMenu = li.getElementsByTagName("ul")[0]; 
	subMenu.style.display = "none"; 
} 


function getURLParam(name){

	  var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
	  return results[1] || 0;
}

function SimpleMessage( szMessage, iTime, handler )
{
	$.blockUI({
		message: szMessage,
		css: {padding:'35px',color:'#CC0000'}
	});
	
	if( iTime != null && handler == null )
		setTimeout( $.unblockUI, iTime );
	
	if( iTime != null && handler != null )
		setTimeout( handler, iTime );
}

function ShowModelDialog( oElement, bCloseAll )
{
	if( bCloseAll == null )
		bCloseAll = false;
	
	
	messageStack.push( oElement );
	
	$("[tag=close_box]").bind( "click", {closeAll: bCloseAll}, exit_ui_box );	
	
	var msgBoxWidth = $(oElement).width();
	
	$.blockUI({message: $(oElement), 
				css:{width: msgBoxWidth + "px",
					  padding:        0,
					  margin:         0,
					  top:            '30%', 
	        		  left:           '35%', 
					  textAlign:      '', 
					  color:          '', 
					  border:         '',
					  backgroundColor:'',       				
					  cursor:         'wait'	
					
				}});
}

function exit_ui_box(event)
{
	if( event.data.closeAll == true )
	{
		messageStack = new Array();
		$.unblockUI();
		return;
	}
	
	messageStack.pop();
	
	if( messageStack.length == 0 )
		$.unblockUI();
	else
	{
		var preUI = messageStack.pop();
		messageStack.push( preUI );
		var msgBoxWidth = $(preUI).width();
		$.blockUI({message: $(preUI), css:{width: msgBoxWidth + "px",
                                            padding:        0,
					  margin:         0,
					  top:            '30%',
                                        left:           '35%'}});
	}
	
}

function BindEvent( szElement, szEvent, oFunction )
{
	$(szElement).unbind( szEvent );
	$(szElement).bind( szEvent, oFunction );
}

function UnblockUI( iTime )
{
	if( iTime != null )
		setTimeout( $.unblockUI, iTime );
	else
		$.unblockUI();
}

var MB_OK = 0;
var MB_YESNO = 1;
var DIALOGUE_PENDING = 2;

function MessageBox( szMessage, szTitle, iButtons, bCloseAll, isRefresh )
{
	               
	if( typeof(iButtons) == "undefined" )
		iButtons = false;
	
	if( typeof(bCloseAll) == "undefined" )
		bCloseAll = false;
	
	if( typeof(szTitle) == "undefined" )
		szTitle = "消息框";
	
	var msgHtml = "";
	
	if( iButtons != false && typeof(iButtons.yes) != "undefined" && typeof(iButtons.no) != "undefined" )
		msgHtml = '<div id="messageBox" style="display:none;cursor:default;" class="popup"><div class="popup1"><div class="popup_title" style="text-align:left;">消息框</div><div tag="close_box" class="popup_close"><a href="###"><span>关闭窗口</span></a></div></div><div class="popup2"><div id="messageContet" style="padding:5px;font-size:12px; font-weight:bold;"></div></div><div class="popup3"><div class="popup_btns"><input type="button" class="btn_1" tag="confirm_box" value="确定">&nbsp; <input type="button" class="btn_1" tag="cancel_box" value="取消"></div></div></div>';
	else
		msgHtml = '<div id="messageBox" style="display:none;cursor:default;" class="popup"><div class="popup1"><div class="popup_title" style="text-align:left;">消息框</div><div tag="close_box" class="popup_close"><a href="###"><span>关闭窗口</span></a></div></div><div class="popup2"><div id="messageContet" style="padding:5px;font-size:12px; font-weight:bold;"></div></div> <div class="popup3"><div class="popup_btns"><input type="button" tag="confirm_box" value="确定" class="btn_1"/></div></div></div>';
	
	
	var elementCount = $("#messageBox").size();
	if( elementCount == 0 )
		$("body").append(msgHtml);
	else
		$("#messageBox").replaceWith( msgHtml );
		
	$("#messageContet").html( szMessage );
	
	$(".popup_title").text(szTitle);
	
	if( iButtons != false )
	{
		if( typeof(iButtons.yes) != "undefined" )
			BindEvent( "input[tag=confirm_box]", "click", iButtons.yes );
		
		if( typeof(iButtons.no) != "undefined" )
			BindEvent( "input[tag=cancel_box]", "click", iButtons.no );
		else
			$("input[tag=cancel_box]").bind( "click", {closeAll: bCloseAll}, exit_ui_box );	
	}
	else
		$("input[tag=confirm_box]").bind( "click", {closeAll: bCloseAll}, exit_ui_box );	
		//BindEvent( "input[tag=confirm_box]", "click", iButtons.yes );
	
	
	$("[tag=close_box]").bind( "click", {closeAll: bCloseAll}, exit_ui_box );	
	
	
	messageStack.push( szMessage );
	
	var msgBoxWidth = $("#messageBox").width();
	
	$.blockUI({message: $("#messageBox"), 
				css:{width: msgBoxWidth + "px",
				
					  padding:        0,
					  margin:         0,
					  top:            '30%', 
	        		  left:           '35%', 
					  textAlign:      '', 
					  color:          '', 
					  border:         '',
					  backgroundColor:'',       				
					  cursor:         'wait'
				}});
	
	   
	//add by bo @0925:增加自动关闭
	var numargs  =  arguments.length;

	if (numargs == 5)  {
			
			$(".popup2").append('<div><span id="tTimeNum">5</span>秒后关闭窗口</div>');
			setClosePopTime('5',isRefresh);	
	}

					
}

//add by bo@0925:增加自动关闭
function setClosePopTime(count,isRefresh){


	window.setTimeout(function()
	{   
		count--;   
		if(count > 0) 
		{   
			$("#tTimeNum").html(count);   
			setClosePopTime(count,isRefresh);   
		} 
		else 
		{if(isRefresh!=false){
	
				window.location.href=window.location.href; 
				  
			}else{
		
				$("#userComment").unblock();
				UnblockUI();
			}
		}   
	}, 1000);   
}


function Login( continueHandler )
{
	if( hasLogin == true )
		return true;
	
	var loginHtml = '<div style="display:none;cursor:default;" class="popup" id="login_popup"><div class="popup1"><div class="popup_title">登陆</div><div id="closeWindow" class="popup_close"><a href="###"><span>关闭窗口</span></a></div> </div> <div class="popup2" > <form method="post" id="login_popup_form" > <input type="hidden" name="action" value="login" /> <table align="center" style="margin-left: auto; margin-right:auto; " > <tr> <td><br/>昵称或Email：</td> <td align="left"><br/><input type="text" id="username" name="username" value=""/></td> </tr> <tr> <td align="right"><br/>输入密码：</td> <td><br/><input type="password" id="pass" name="pass"/></td> </tr> </table> <p class="lc" align="center"><input name="login_cookie" type="checkbox" checked="checked" /> 一个月之内免登录</p><br/> <div class="popup_btns"> <input type="button" class="btn_1" value="登录" tag="login_popup_commit"/> <input type="button" class="btn_1" value="取消" tag="cancel_box" /></div> </form> </div><div class="popup3"></div></div>';
	
	var elementCount = $("#login_popup").size();
	if( elementCount == 0 )
		$("body").append(loginHtml);
	
	$(".popup_close").bind( "click", {closeAll: true}, exit_ui_box );
	$("input[tag=cancel_box]").bind( "click", {closeAll: true}, exit_ui_box );	
	
    $("#pass").bind( "keydown", {button: $('input[tag=login_popup_commit]')}, PressKeyDown );	
	
	
	var validator = $("#login_popup_form").validate({	 
	     rules:{      
			username: {required: true, maxlength: 50},
		   	pass: {required: true , minlength: 6, maxlength: 20}
	     },
	     messages:{
	        username: {required:"请输入登陆账户", maxlength:'最多输入50个字符'},
	        pass: {required:"请输入登陆密码", minlength:'最少输入6个字符', maxlength:'最多输入20个字符'}
	     },
	     submitHandler: function(form) 
	     {
	    	return true;
	     }
	   });
	
	BindEvent( "input[tag=login_popup_commit]", "click", function(){
		
		 var params = $('#login_popup_form').serialize();
	      $.ajax(
	    	{
	                type: 'post',
	                url: edp_domain_url + 'login/?tiny=1',
	                data: params,
	                global:false,
		            beforeSend: function() {},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						MessageBox( "错误，请稍后再试..." + errorThrown);
					},
	                success: function( data, textStatus ) {
                                                var len = data.toString().length;
                                                var ind = data.toString().substr( len-1, 1 );
						if(  ind != '0' ){
							MessageBox( data );
						}
						else{
							$.unblockUI();
							hasLogin = true;
							continueHandler();
							ChangeHeaderAfterLogin();
							//$("#add_review_form").trigger("submit");  
						}
							
	                }
	         });
		
	});
		
	ShowModelDialog( "#login_popup" );
	return false;
	    
}

function PressKeyDown(event){

	if(event.keyCode==13){
		var button=event.data.button;
		button.click();
	}
}


function GetFuncType( target, funcObject ){

	if( funcObject.data != 'undefined' ){
					
		return function(){
			$(target).trigger( 'submit', funcObject.data );
		};
	}
	
	return function(){
		$(target).trigger( 'submit' );
	};
}	 
 
function GetFormSubmitEvent( formEle ){
	
	if( formEle.onsubmit != null )
		return formEle.onsubmit;
	
	
	var events = jQuery.data( formEle, 'events' )['submit'];
	var handler = null;
	for( var n in events )
		handler = events[n];
	
	if( handler != null )
		return GetFuncType( formEle, handler);
	
	return null;
}

function ChangeHeaderAfterLogin()
{
	$('.topbar_login').html('您好，欢迎来到花开里！<a href="' + edp_domain_url + 'user_info">欢迎回来</a> <a href="' + edp_domain_url + 'mail_inbox">站内信</a> <a href="' + edp_domain_url + 'my_edp">我的E点评</a><a href="' + edp_domain_url + 'logout">退出</a>');
}

function CheckLogin()
{
	var start = document.cookie.indexOf( 'huakaili=' ); 
	if( start == -1 || $('.topbar_login a').length > 2 || $('.userToolbar_back').length == 1 )
		return;
	else{
		$.ajax({
            type: 'post',
            url: edp_domain_url + '/ajax_check_login/?tiny=1',
            timeout: 5000,
			global:false,
			error: function(XMLHttpRequest, textStatus, errorThrown)
			{
				return;
			},
            success: function( data, textStatus )
            {
				if( data == '-1')
					return;
				$('.topbar_login').html( data );
            }
		});
	}
		
}

function CommitHandler(){
			
			var a = $("form[grayOnCommit]");
						
			for( var i = 0; i < a.length; i++)
			{
				
				var ele = $("form[grayOnCommit]")[i];
				//store original handlers
				var handlers = new Array();			

				jEvents = jQuery.data( ele, 'events');
				
				if( jEvents != null )
				{
					var events = jEvents.submit;
					for( var n in events )
						handlers.push( events[n].handler );
				}
				
				if( ele.onsubmit != null )
					handlers.push( ele.onsubmit );
				
				// unhook the original handlers
				$(ele).unbind('submit');
				ele.onsubmit = null;
				
				// rebind the submit to the proxy handler
				$(ele).bind( 'submit', {phandlers: handlers, target: $(ele).attr("grayOnCommit")}, SubmitProxy );
				
			}
}

/*
 * these script is for disable the form after the user commit to prevent the user from
 * resubmit the form.
 * yawei
 */
function SubmitProxy( event )
{
	var handlers = event.data.phandlers;
	var target = event.data.target;

	// trigger all the events associated with the submit action
	var result = true;
	for( var n in handlers )
		if( handlers[n]() == false )
			result = false;
	
	// submit fails, restore the blocked form
	if( result == false )
		return false;

	// blocking the form submitted
	var msgHTML = '<div class="progressbar" style="width:145px; height:15px;"></div>';
	var blockedTarget = $(target);
	$(blockedTarget).block({message: msgHTML, css: {width: '145px'}});

	
	return true;

}

$(document).ready(function(){
	SetFocus();
	Initialize();
	CheckLogin();
}
);

function CheckSearchAction(){
        if( $("#keyword").val() == "输入店铺名、掌柜名进行搜索..." ){
                $("#keyword").val("");
        }
}

function SetFocus(){
        //      var str = $("#keyword").val();
        //when search input box set to focus, clear the field
        $("#keyword").focus(
                function(){
                        if( $("#keyword").val() == "输入店铺名、掌柜名进行搜索..." ){
                                $("#keyword").val("");
                        }
                }
        )
        $("#keyword").blur(
                function(){
                        if( $("#keyword").val() == "" ){
                                $("#keyword").val("输入店铺名、掌柜名进行搜索...");
                        }
                }
        )
}

function Initialize(){
        // add search type action
        $("#searchtype").change(
                function () {
                        var str = $("#searchtype option:selected").val();
                        var platid = $("#searchtype option:selected").attr("platid");
			$("#platid").val( platid );
                        //$("#page").val(str);
                        $( "#searchform" ).attr("action", str );
                });

        $( "#searchform" ).submit(
                function(){
                        CheckSearchAction();
                });

        var str = $('#keyword').val();
        if( "" == str ){
                $("#keyword").val("请输入要搜索的关键词");
        }
        else{
                $("#keyword").val( str );
        }
}


//copy 要复制的内容
function CopyToClipboard(copyText)
{
	 if (window.clipboardData) 
     {
         window.clipboardData.setData("Text", copyText)
     } 
     else 
     {
         var flashcopier = 'flashcopier';
         if(!document.getElementById(flashcopier)) 
         {
           var divholder = document.createElement('div');
           divholder.id = flashcopier;
           document.body.appendChild(divholder);
         }
         document.getElementById(flashcopier).innerHTML = '';
         var divinfo = '<embed src="../js/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(copyText)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
         document.getElementById(flashcopier).innerHTML = divinfo;
     }
	 alert('已复制'+copyText);

}

function ShowMessageBoxWithCallBack( msg )
{
    MessageBox( msg, '消息',
        {yes: function()
            {if(typeof(PageCallBackFunc) == 'function')
                    PageCallBackFunc();

              UnblockUI();
            }
        }
    );
}
